    <script>

        var container, stats;

        var camera, scene, renderer;

        var targetRotation = 0;
        var targetRotationOnMouseDown = 0;

        var mouseX = 0;
        var mouseXOnMouseDown = 0;

        var windowHalfX = window.innerWidth / 2;
        var windowHalfY = window.innerHeight / 2;

        var mesh;
        var left,right,front,top,bottom,back;

        var clock = new THREE.Clock();

        init();
        animate();

        function init() {

            container = document.getElementById( 'container' );

            scene = new THREE.Scene();

            camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
            camera.position.y = 150;
            camera.position.z = 500;
            scene.add( camera );

            var r = "obj/Bridge2/";
            var left = loadTexture(  r + "posx.jpg" );
            right = loadTexture(  r + "posy.jpg" );
            front = loadTexture(  r + "posz.jpg" );
            top = loadTexture(  r + "negx.jpg" );
            bottom = loadTexture(  r + "negy.jpg" );
            back = loadTexture(  r + "negz.jpg" );
            var materials = [

            right, // right
            left, // left
            top, // top
            bottom, // bottom
            back, // back
            front  // front

            ];

            cubes= new THREE.CubeGeometry( 100, 100, 100, 1, 1, 1, materials);

            mesh = new THREE.Mesh( cubes, new THREE.MeshFaceMaterial() );
            mesh.position.y = 150;
            scene.add( mesh );

            var ambientLight = new THREE.AmbientLight( 0xcccccc );
            scene.add( ambientLight );

            var directionalLight = new THREE.DirectionalLight( 0xffffff, 2 );
            directionalLight.position.set( 1, 1, 0.5 ).normalize();
            scene.add( directionalLight );

            renderer = new THREE.WebGLRenderer( { clearColor: 0xbfd1e5 } );
            renderer.setSize( window.innerWidth, window.innerHeight );

            container.innerHTML = "";

            container.appendChild( renderer.domElement );

            stats = new Stats();
            stats.domElement.style.position = 'absolute';
            stats.domElement.style.top = '0px';
            container.appendChild( stats.domElement );

            document.addEventListener( 'mousedown', onDocumentMouseDown, false );
            document.addEventListener( 'keydown', onDocumentKeyDown, false );
        }

        function loadTexture( path ) {

            var image = new Image();
            image.onload = function () {
                texture.needsUpdate = true;
            };
            image.src = path;

            var texture  = new THREE.Texture( image, new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping, THREE.NearestFilter, THREE.LinearMipMapLinearFilter );

            return new THREE.MeshLambertMaterial( { map: texture, ambient: 0xbbbbbb } );

        }

        function changeTexture() {

            cubes.materials[4]=loadTexture( "obj/sofa/texture0.jpg" );
        }

        function onDocumentKeyDown(event) {
            switch(event.keyCode) {
                case 32:
                    changeTexture();
                    break;
            }
        }

        //

        function onDocumentMouseDown( event ) {

            event.preventDefault();

            document.addEventListener( 'mousemove', onDocumentMouseMove, false );
            document.addEventListener( 'mouseup', onDocumentMouseUp, false );
            document.addEventListener( 'mouseout', onDocumentMouseOut, false );

            mouseXOnMouseDown = event.clientX - windowHalfX;
            targetRotationOnMouseDown = targetRotation;
        }

        function onDocumentMouseMove( event ) {

            mouseX = event.clientX - windowHalfX;

            targetRotation = targetRotationOnMouseDown + ( mouseX - mouseXOnMouseDown ) * 0.02;
        }

        function onDocumentMouseUp( event ) {

            document.removeEventListener( 'mousemove', onDocumentMouseMove, false );
            document.removeEventListener( 'mouseup', onDocumentMouseUp, false );
            document.removeEventListener( 'mouseout', onDocumentMouseOut, false );
        }

        function onDocumentMouseOut( event ) {

            document.removeEventListener( 'mousemove', onDocumentMouseMove, false );
            document.removeEventListener( 'mouseup', onDocumentMouseUp, false );
            document.removeEventListener( 'mouseout', onDocumentMouseOut, false );
        }

        //

        function animate() {

            requestAnimationFrame( animate );

            render();
            stats.update();

        }

        function render() {
            mesh.rotation.y += ( targetRotation - mesh.rotation.y ) * 0.05;
            renderer.render( scene, camera );

        }

    </script>
